package imp.core.data;

import imp.core.debug.DebugManager;


/**
 * This class containts basic session data used in the program.
 * @author Patrick Arnold
 * @since 08.09.2010
 *
 */
public class SessionData {

	/** The start time of the program (in ms). */
	private static long startTime;
	
	/** Specifies whether the debug mode is enabled or not. */
	private static boolean debugMode;

	
	
	/**
	 * Initializes the session data.
	 * @param startTime The start time of the program.
	 * @param debug Specifies whether the debug mode is enabled or not.
	 */
	public static void initializeSessionData( long startTime, boolean debug) {
		
		SessionData.startTime = startTime;
		SessionData.debugMode = debug;
		
		if( SessionData.isDebugMode()) {
			String[] output = new String[4];
			output[0] = "Runtime:      [" + SessionData.getCurrentRuntime() + " ms]";
			output[1] = "";
			output[2] = "Start time:   " + startTime + " ms";
			output[3] = "Debug mode:   " + debug;
			DebugManager.displayStringField( output, "Session Data");
		}
		
	}
	
	
	
	/**
	 * Returns the start time of the program.
	 * @return The start time.
	 */
	public static long getStarttime() {
		return startTime;
	}


	/**
	 * Returns whether the debug mode is enabled or not.
	 * @return Specifies whether the debug mode is enabled or not.
	 */
	public static boolean isDebugMode() {
		return debugMode;
	}

	
	/**
	 * Returns the current runtime of the program.
	 * @return The current runtime of the program (in ms).
	 */
	public static long getCurrentRuntime() {
	
		long runtime = System.currentTimeMillis() - startTime;
		return runtime;
	
	}
	
	
}